package algorithm.Stack;

import java.util.Stack;

/**
 * @Author: 李浩然
 * @Date: 2021/1/4 10:56 上午
 */
public class minStack {
    private Stack<Integer> dataStack = new Stack<>();
    private Stack<Integer> minStack = new Stack<>();

    public void push(int node) {
        dataStack.add(node);
        minStack.add(minStack.isEmpty() ? node : Math.min(minStack.peek(), node));
    }

    public void pop() {
        dataStack.pop();
        minStack.pop();
    }

    public int top() {
        return dataStack.peek();
    }

    public int min() {
        return minStack.peek();
    }
}
